//
//  DisSecCollectionViewCell.m
//  LT
//
//  Created by dllo on 16/5/17.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "DisSecCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation DisSecCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubview];
    }
    return self;

}

-(void)createSubview{
    self.disPhotoImage = [[UIImageView alloc]init];
    [self.contentView addSubview:self.disPhotoImage];
    self.disPhotoImage.backgroundColor = [UIColor clearColor];
    
    self.disTitle = [[UILabel alloc]init];
     [self.contentView addSubview:self.disTitle];
    self.disTitle.backgroundColor = [UIColor clearColor];
    
    self.disPriceoff = [[UILabel alloc]init];
    [self.contentView addSubview:self.disPriceoff];
   self.disPriceoff.backgroundColor = [UIColor clearColor];
    
    self.disPrice = [[UILabel alloc]init];
    [self.contentView addSubview:self.disPrice];
    self.disPrice.backgroundColor = [UIColor clearColor];
    


}

//给坐标
-(void)layoutSubviews{
    [super layoutSubviews];
    self.disPhotoImage.frame = CGRectMake(0 * WIDTHCELL,0 * WIDTHCELL, 195 * WIDTHCELL , 120 * WIDTHCELL);
    self.disTitle.frame = CGRectMake(0* WIDTHCELL,120 * WIDTHCELL, 195* WIDTHCELL, 50 * WIDTHCELL);
    self.disPriceoff.frame = CGRectMake(5* WIDTHCELL, 170* WIDTHCELL, 70* WIDTHCELL, 20* WIDTHCELL);
    self.disPrice.frame = CGRectMake(125* WIDTHCELL, 170* WIDTHCELL, 80* WIDTHCELL, 20* WIDTHCELL);
    self.disPrice.textColor = [UIColor redColor];

}


//重写setter方法传值
-(void)setDiscount:(DisTwoModel *)discount{
    _discount = discount;
   
    //传图片
    [self.disPhotoImage sd_setImageWithURL:[NSURL URLWithString:_discount.photo] placeholderImage:[UIImage imageNamed:@"LETU"]];
    //传题目
    self.disTitle.text = _discount.title;
    self.disTitle.font = [UIFont systemFontOfSize:15];
    
    //传价格折扣label
    self.disPriceoff.text = _discount.priceoff;
    self.disPriceoff.font = [UIFont systemFontOfSize:13];
    
    //传价格(只截取价格,从第四个位置开始往后取五个)
//    self.disPrice.text = [_discount.price substringWithRange:NSMakeRange(4, 5)];
 
    NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z.<,>,/]" options:0 error:NULL];
    NSString *string = _discount.price;
    NSString *price= [regular stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@""];
    self.disPrice.text = price;
    
    
    
}







@end
